﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="detailandmed_v5_kp_pandipidaja", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(DetailandmedV5KpPandipidaja))]
    public class DetailandmedV5KpPandipidajaSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDetailandmedV5KpPandipidaja clazz;
        
        public DetailandmedV5KpPandipidajaSerializer(IDetailandmedV5KpPandipidaja clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.KirjeId!=null) {
                Writer.WriteStartElement("kirje_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.KirjeId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KaardiPiirkond!=null) {
                Writer.WriteStartElement("kaardi_piirkond");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.KaardiPiirkond))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KaardiNr!=null) {
                Writer.WriteStartElement("kaardi_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.KaardiNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KaardiTyyp!=null) {
                Writer.WriteStartElement("kaardi_tyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KaardiTyyp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KandeNr!=null) {
                Writer.WriteStartElement("kande_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.KandeNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PidajaIsikuliik!=null) {
                Writer.WriteStartElement("pidaja_isikuliik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PidajaIsikuliik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PidajaNimi!=null) {
                Writer.WriteStartElement("pidaja_nimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PidajaNimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PidajaKood!=null) {
                Writer.WriteStartElement("pidaja_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PidajaKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PidajaRiik!=null) {
                Writer.WriteStartElement("pidaja_riik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PidajaRiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PidajaRiikTekstina!=null) {
                Writer.WriteStartElement("pidaja_riik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PidajaRiikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PidajaAsukohtEhak!=null) {
                Writer.WriteStartElement("pidaja_asukoht_ehak");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PidajaAsukohtEhak))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PidajaAsukohtEhakTekstina!=null) {
                Writer.WriteStartElement("pidaja_asukoht_ehak_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PidajaAsukohtEhakTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PidajaMurdosa!=null) {
                Writer.WriteStartElement("pidaja_murdosa");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PidajaMurdosa))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKpv!=null) {
                Writer.WriteStartElement("algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKpv!=null) {
                Writer.WriteStartElement("lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="kirje_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>kirje_id");
                }
                clazz.KirjeId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("kirje_id")).Value;
            }
            if (Reader.LocalName=="kaardi_piirkond") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>kaardi_piirkond");
                }
                clazz.KaardiPiirkond = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("kaardi_piirkond")).Value;
            }
            if (Reader.LocalName=="kaardi_nr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>kaardi_nr");
                }
                clazz.KaardiNr = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("kaardi_nr")).Value;
            }
            if (Reader.LocalName=="kaardi_tyyp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>kaardi_tyyp");
                }
                clazz.KaardiTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kaardi_tyyp")).Value;
            }
            if (Reader.LocalName=="kande_nr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>kande_nr");
                }
                clazz.KandeNr = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("kande_nr")).Value;
            }
            if (Reader.LocalName=="pidaja_isikuliik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>pidaja_isikuliik");
                }
                clazz.PidajaIsikuliik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pidaja_isikuliik")).Value;
            }
            if (Reader.LocalName=="pidaja_nimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>pidaja_nimi");
                }
                clazz.PidajaNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pidaja_nimi")).Value;
            }
            if (Reader.LocalName=="pidaja_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>pidaja_kood");
                }
                clazz.PidajaKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pidaja_kood")).Value;
            }
            if (Reader.LocalName=="pidaja_riik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>pidaja_riik");
                }
                clazz.PidajaRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pidaja_riik")).Value;
            }
            if (Reader.LocalName=="pidaja_riik_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>pidaja_riik_tekstina");
                }
                clazz.PidajaRiikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pidaja_riik_tekstina")).Value;
            }
            if (Reader.LocalName=="pidaja_asukoht_ehak") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>pidaja_asukoht_ehak");
                }
                clazz.PidajaAsukohtEhak = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pidaja_asukoht_ehak")).Value;
            }
            if (Reader.LocalName=="pidaja_asukoht_ehak_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>pidaja_asukoht_ehak_tekstina");
                }
                clazz.PidajaAsukohtEhakTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pidaja_asukoht_ehak_tekstina")).Value;
            }
            if (Reader.LocalName=="pidaja_murdosa") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>pidaja_murdosa");
                }
                clazz.PidajaMurdosa = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pidaja_murdosa")).Value;
            }
            if (Reader.LocalName=="algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>algus_kpv");
                }
                clazz.AlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kpv")).Value;
            }
            if (Reader.LocalName=="lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_kp_pandipidaja>lopp_kpv");
                }
                clazz.LoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kpv")).Value;
            }
        }
    }
}
